<script>
$(document).ready(function () {
    $('select[name="parentId[]"]').each(function () {
        attr_select_init_data(this);
    });
});

function attr_select_init_data (item) 
{
        var sel = $(item).parent().parent().parent().find('select[name="attrId[]"]').get();
        url = '/api/attr/options_subattr';
        data = { value : $(item).val() };
        $.post(url, data, function (o) {
            if (o.status == 0)
                $(sel).html(o.html);
                var id = $(sel).attr('val');
                if (id > 0)
                {
                    $(sel).val(id);
                }
        }, 'json');
}
</script>
